package org.vincen.helloworld.annotation;

import java.lang.reflect.Method;


public class MyReflection {
	
	public static void main(String[] args) throws Exception {
		PractiseAnnotation pa = new PractiseAnnotation();
		Class<PractiseAnnotation> c = PractiseAnnotation.class;
		Method method = c.getMethod("output", new Class[]{});
		if (method.isAnnotationPresent(AnnotationTest.class)) {
			method.invoke(pa, new Object[]{});
			AnnotationTest annotation = method.getAnnotation(AnnotationTest.class);
			//也可以这么写，但是使用这样写法，annotation就不能调用AnnotationTest里边的方法
			//Annotation annotation = method.getAnnotation(Annotation.class);
			String hello = annotation.hello();
			String world = annotation.world();
			
			System.out.println(hello);
			System.out.println(world);
		}
	}
}
